<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="/js/plugin/layui-v2.3.0/layui/css/layui.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/index.css">
	<link rel="stylesheet" href="/css/project_set.css">
	<script src="/js/jquery-2.1.1.min.js"></script>
	<script src="/js/plugin/layui-v2.3.0/layui/layui.js"></script>
	<script src="/js/common.js"></script>
<script>
	$(document).ready(function() {
		$.post("/system/org/dept/selectjson/0",function(res){
			$("#deptid").append("<option value=''></option>");  
			for(var i=0;i<res.length;i++){
				//console.log(res)
				$("#deptid").append("<option value='"+res[i].id+"'>"+res[i].text+"</option>");  
				
			}
	    },"json"); 
		
		initFormSelects("teamUserid","/system/org/user/selectjson","");
		initFormSelects("userids","/system/org/user/selectjson","");
		initFormSelects("projectProvince","/system/province/selectjson/0_","");
	    
	});
	
</script>
<style>
.layui-form-label{
	text-align:left
}
.kb-form-container{
	padding-left:20px;
}
.layui-form-item .layui-inline{
	margin-right:0px
}
</style>
</head>
<body style="overflow-y:scroll">
<div class="addemployee-wrap" id="employee-wrap">
	<div class="kb-form-container" >
		<form class="layui-form" id="defaultForm" th:action="@{/app/project/save}" th:method="post" lay-filter="employee-form">
			<fieldset class="fieldset">
				<div class="layui-form-item">
					<div class="layui-inline">
					    <label class="layui-form-label"><span class="must-fill">*</span>分店名称</label>
					    <div class="layui-input-inline" style="width:330px">
					      	<input type="text" name="projectName" id="projectName" required  lay-verify="projectName" placeholder="" autocomplete="off" class="layui-input">
					    	<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">输入分店名,如三元桥店</span>
					    </div>
					</div>
					<div class="layui-inline">
					    <label class="layui-form-label" style="width:30px">编号</label>
					    <div class="layui-input-inline" style="width:120px">
					    	<input type="text" name="projectNumber" id="projectNumber" placeholder="" autocomplete="off" class="layui-input">
					    	<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">内部的分店编号</span>
					    </div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
					    <label class="layui-form-label"><span class="must-fill">*</span>省份</label>
					    <div class="layui-input-inline" style="width:140px">
					      	<select name="projectProvince" id="projectProvince" onchange="" lay-filter="projectProvince" required  lay-verify="projectProvince">
						    </select>
					    </div>
					</div>
					<div class="layui-inline">
					    <label class="layui-form-label" style="width:36px;padding:9px 0px"><span class="must-fill">*</span>城市</label>
					    <div class="layui-input-inline" style="width:140px">
					    	<select name="projectCity" id="projectCity" lay-filter="projectCity" required  lay-verify="projectCity">
						    </select>
					    </div>
					</div>
					<div class="layui-inline">
					    <label class="layui-form-label" style="width:30px;padding:9px 0px"><span class="must-fill">*</span>区</label>
					    <div class="layui-input-inline" style="width:150px">
					    	<select name="projectRegion" id="projectRegion" lay-filter="projectRegion" required  lay-verify="projectRegion">
						    </select>
					    </div>
					</div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label"><span class="must-fill">*</span>地址</label>
				    <div class="layui-input-block">
				      	<textarea placeholder="请输入内容" id="projectAddress"  required  lay-verify="projectAddress" name="projectAddress" class="layui-textarea"></textarea>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">电话</label>
				    <div class="layui-input-block">
				      	<input type="text" name="projectTelephone" id="projectTelephone" required  lay-verify="pwd" placeholder="" autocomplete="off" class="layui-input">
				    	<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">输入外部联系电话号码</span>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label"><span class="must-fill">*</span>面积</label>
				    <div class="layui-input-block">
				      	<input type="text" name="projectArea" id="projectArea"  required  lay-verify="projectArea" placeholder="" autocomplete="off" class="layui-input">
				    	<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">分店总体面积平方米数</span>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">排序位</label>
				    <div class="layui-input-block">
				      	<input type="text" name="sortNumber" placeholder="" autocomplete="off" class="layui-input">
				    	<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">请输入数字，修改客户端的社区位置，数字越大排上面</span>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">自行绑卡</label>
				    <div class="layui-input-block">
				      	<select name="card" lay-filter="aihao">
					        <option value="">请选择</option>
					        <option value="0">允许用户绑定门禁IC卡</option>
					    	<option value="1">不允许用户绑定门禁IC卡</option>
					    </select>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">触摸密码</label>
				    <div class="layui-input-block">
				      	<select name="touchPassword" lay-filter="aihao">
					        <option value="">请选择</option>
					        <option value="0">允许用户设置触摸密码</option>
					    	<option value="1">不允许用户设置触摸密码</option>
					    </select>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">蓝牙门禁</label>
				    <div class="layui-input-block">
				    	<select name="bluetoothEntrance" lay-filter="aihao">
					        <option value="">请选择</option>
					        <option value="0">显示蓝牙门禁</option>
					    	<option value="1">不显示蓝牙门禁</option>
					    </select>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label"><span class="must-fill">*</span>简介</label>
				    <div class="layui-input-block">
				      	<textarea placeholder="请输入内容" id="introduction" required  lay-verify="introduction"  name="introduction" class="layui-textarea"></textarea>
				    </div>
				</div>
			</fieldset>
			<fieldset class="fieldset">
	           <legend>甲方信息</legend>
				<div class="layui-form-item">
				    <label class="layui-form-label">名称</label>
				    <div class="layui-input-block">
				      	<input type="text" name="partyName" id="partyName" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">地址</label>
				    <div class="layui-input-block">
				      	<input type="text" name="partyAddress" id="partyAddress" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">开户行</label>
				    <div class="layui-input-block">
				      	<input type="text" name="partyOpening" id="partyOpening" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">账号</label>
				    <div class="layui-input-block">
				      	<input type="text" name="partyAccount" id="partyAccount" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">联系电话</label>
				    <div class="layui-input-block">
				      	<input type="text" name="partyTelephone" id="partyTelephone" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				</div>
			</fieldset>
			<fieldset class="fieldset">	
				<legend>管理团队</legend>
				<div class="layui-form-item">
				    <label class="layui-form-label"><span class="must-fill">*</span>负责人</label>
				    <div class="layui-input-block">
				    	<select name="teamUserid" id="teamUserid" lay-filter="teamUserid" required  lay-verify="teamUserid" >
					        <option value="">请选择</option>
					    </select>
					    <span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">分店的总体负责人,如分店长或分店经理</span>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">员工</label>
				    <div class="layui-input-block">
				    	<select name="city" id="userids" name="userids" lay-verify="userids" xm-select="userid" xm-select-skin="normal" xm-select-type="1">
					        <option value="">请选择</option>
					    </select>
					    <input type="hidden" id="teamUserids" name="teamUserids" />
					    <span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">分店的其他运营人员,可多选</span>
				    </div>
				</div>
				<div class="layui-form-item">
					<a class="layui-btn layui-btn-normal btn-bg" style="margin-left:66px;">上传图片</a>
					<br>
					<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">允许多张上传,格式为png或jpg,大小不大于20M</span>
				</div>
				<div class="layui-form-item" style="">
				    <div class="layui-input-block">
				      <button class="layui-btn layui-btn-normal btn-bg" lay-submit lay-filter="formEmployee" id="submit-btn">提交</button>
				      <a class="layui-btn layui-btn-primary" onclick="closeLayer()">取消</a>
				    </div>
				</div>
			</fieldset>
		</form>	
	</div>
</div>
</body>
<script>
	
	layui.config({
	        base: '/js/plugin/layui-v2.3.0/layui/' //此处路径请自行处理, 可以使用绝对路径
	    }).extend({
	        formSelects: 'formSelects-v3'
	    }).use(['element',"layer","form",'formSelects'], function(){
			var layer=layui.layer,form = layui.form,formSelects = layui.formSelects;
			form.on('select(projectProvince)', function(data){
				initFormSelects("projectCity","/system/province/selectjson/1_"+data.value,"");
			});
			form.on('select(projectCity)', function(data){
				initFormSelects("projectRegion","/system/province/selectjson/2_"+data.value,"");
				//form.render('select')
			});
			 
			form.verify({
				projectName: function(value, item){ //value：表单的值、item：表单的DOM对象
		      	  if(value==""){
			       	  return '分店名称不能为空';
			      }
			  }
				,projectProvince: function(value, item){ //value：表单的值、item：表单的DOM对象
		      	  if(value==""){
			       	  return '省份不能为空';
			      }
			  }
				,projectCity: function(value, item){ //value：表单的值、item：表单的DOM对象
		      	  if(value==""){
			       	  return '城市不能为空';
			      }
			  }
			  ,projectAddress: function(value, item){ //value：表单的值、item：表单的DOM对象
		      	  if(value==""){
			       	  return '地址不能为空';
			      }
			  }
			  ,projectArea: function(value, item){ //value：表单的值、item：表单的DOM对象
			    if(value==""){
			    	return '面积不能为空';
			    }else if(!new RegExp("^\\d+(\\.\\d+)?$").test(value)){
			      return '面积不能有特殊字符';
			    }
			  }
			  ,introduction: function(value, item){ //value：表单的值、item：表单的DOM对象
			     if(value==""){
			     	return '简介不能为空';
			     }
			  }
			  ,userids: function(value, item){ //value：表单的值、item：表单的DOM对象
				  var con="";
				  for(var i=0;i<formSelects.value('userid').length;i++){
					  con+=","+formSelects.value('userid')[i].val;
				  }
				  $("#teamUserids").val(con.substring(1));
			  }
			  
			}); 
			//监听提交
			  form.on('submit(formEmployee)', function(data){
				  $.post($("#defaultForm").attr('action'), data.field, function(result) {
						window.parent.layer.msg(result.msg);
						closeLayer();
					}, 'json');
					return false;
			  });
			
		});
	 // 创建一个Select
var createSelect = function(optionData) {
      var html = '';
      html += '<div class="layui-input-inline">';
      html += ' <select lay-filter="demo">';
      html += '  <option value="">请选择</option>';
      for(var i = 0; i < optionData.length; i++) {
        html += '  <option value="' + optionData[i].id + '">' + optionData[i].name + '</option>';
      }
      html += ' </select>';
      html += '</div>';
      return html;
}
</script>
</html>